﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.JShop.UI;
using CNVP.Framework;
using System.Data;
using CNVP.Framework.Utils;

namespace CNVP.JShop.Web.Admin
{
    public partial class ProTypeRefAll : AdminPage
    {
        BLL.CNVP_ProductType bll = new BLL.CNVP_ProductType();
        Model.CNVP_ProductType model = new Model.CNVP_ProductType();
        BLL.CNVP_ProTypeRefBranks bll_refbranks = new BLL.CNVP_ProTypeRefBranks();
        BLL.CNVP_ProTypeRefExtendProperty bll_property = new BLL.CNVP_ProTypeRefExtendProperty();
        Model.CNVP_ProTypeRefStandard model_RefStandard = new Model.CNVP_ProTypeRefStandard();
        BLL.CNVP_ProTypeRefStandard bll_RefStandard = new BLL.CNVP_ProTypeRefStandard();
        int id = 0;
        byte IsEntityType = 0;
        byte IsRefBranks = 0;
        public byte IsRefExtendProperty = 0;
        public byte IsRefDescripttion = 0;
        public byte IsRefShopMustInfo = 0;
        public string optionNull = "";
        public string optionEditNull = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!BLL.BLLCheckAdmin.LoginOk(Page, 0)) return;//判断页面权限
            #region 传入参数
            if (!string.IsNullOrEmpty(Request.QueryString["ID"]) && Public.IsNumber(Request.QueryString["ID"]))
            {
                id = Convert.ToInt32(Request.QueryString["ID"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["IsEntityType"]))
            {
                IsEntityType = byte.Parse(Request.QueryString["IsEntityType"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["IsRefBranks"]))
            {
                IsRefBranks = byte.Parse(Request.QueryString["IsRefBranks"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["IsRefExtendProperty"]))
            {
                IsRefExtendProperty = byte.Parse(Request.QueryString["IsRefExtendProperty"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["IsRefDescripttion"]))
            {
                IsRefDescripttion = byte.Parse(Request.QueryString["IsRefDescripttion"]);
            }
            if (!string.IsNullOrEmpty(Request.QueryString["IsRefShopMustInfo"]))
            {
                IsRefShopMustInfo = byte.Parse(Request.QueryString["IsRefShopMustInfo"]);
            }
            #endregion

            if (!IsPostBack)
            {
                if (IsRefBranks == 1)
                {
                    IsBranks.Visible = true;
                    CBBranksBind();
                }
                if (id > 0)
                {
                    lbTitle.Text = " > 修改 > 基本设置";
                    DataInfo(id);
                }
                else
                {
                    lbTitle.Text = " > 添加 > 基本设置";
                }
                StandardBind();
            }
        }
        private void StandardBind()
        {
            CNVP.JShop.Model.CNVP_Standard model_Standard = new CNVP.JShop.Model.CNVP_Standard();
            CNVP.JShop.BLL.CNVP_Standard bll_Standard = new CNVP.JShop.BLL.CNVP_Standard();
            DataTable dt = bll_Standard.GetTableBySqlWhere("");
            optionNull = "<select id=\"ddlStandardID\" name=\"ddlStandardID\">";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                optionNull += " <option title=\"" + dt.Rows[i]["StandardOtherName"].ToString() + "\" value=\"" + dt.Rows[i]["ID"].ToString() + "\">" + dt.Rows[i]["StandardName"].ToString() + "</option>";
            }
            optionNull += "</select>";
        }
        private void CBBranksBind()
        {
            var Branks_List = new BLL.CNVP_Branks().GetAll_CNVP_Branks();
            if (Branks_List.Count > 0)
            {
                cbRefBranks.DataSource = Branks_List;
                cbRefBranks.DataTextField = "BrankName";
                cbRefBranks.DataValueField = "ID";
                cbRefBranks.DataBind();
            }
            else
            {
                lbRefBranks.Text = "无记录！";
            }
        }

        private void DataInfo(int id)
        {
            model = bll.GetSingle_CNVP_ProductTypeById(id);
            if (model != null)
            {
                txtProTypeName.Text = model.ProTypeName;
                #region 关联品牌显示
                string BranksIDS = bll_refbranks.GetSingle_CNVP_ProTypeRefBranksByProductTypeID(id).BranksIDS;
                if (BranksIDS != "")
                {
                    string[] TextBranksIDS = BranksIDS.Split(Convert.ToChar(","));//司机显示

                    for (int i = 0; i < TextBranksIDS.Length; i++)
                    {
                        string item = TextBranksIDS[i].ToString();
                        //Response.Write(item);
                        for (int j = 0; j < cbRefBranks.Items.Count; j++)
                        {
                            if (item == cbRefBranks.Items[j].Value)
                            {
                                cbRefBranks.Items[j].Selected = true;
                            }
                        }
                    }
                }
                #endregion
                #region 扩展信息
                rptList.DataSource = new BLL.CNVP_ProTypeRefExtendProperty().GetAll_CNVP_ProTypeRefExtendProperty(id);
                rptList.DataBind();
                #endregion
                #region 购物必填
                rptListTabs5.DataSource = new BLL.CNVP_ProTypeRefShopMustInfo().GetAll_CNVP_ProTypeRefShopMustInfo(id);
                rptListTabs5.DataBind();
                #endregion
                #region 详细参数
                rptListTabs4.DataSource = new BLL.CNVP_ProTypeRefDescripttion().GetAll_CNVP_ProTypeRefDescripttion(id);
                rptListTabs4.DataBind();
                #endregion
                #region 规格
                rptListTabs2.DataSource = new BLL.CNVP_ProTypeRefStandard().GetAll_CNVP_ProTypeRefStandard(id);
                rptListTabs2.DataBind();
                #endregion
            }
        }

        protected void btUp_Click(object sender, EventArgs e)
        {
            if (id > 0)
            {
                #region 修改商品类型
                int rows = new BLL.CNVP_ProductType().Update_CNVP_ProductType(
                       new Model.CNVP_ProductType()
                       {
                           ID = id,
                           ProTypeName = txtProTypeName.Text.Trim(),
                           IsEntityType = IsEntityType,
                           IsRefBranks = IsRefBranks,
                           IsRefExtendProperty = IsRefExtendProperty,
                           IsRefDescripttion = IsRefDescripttion,
                           IsRefShopMustInfo = IsRefShopMustInfo
                       }

                 );
                #endregion
                #region 修改品牌关联信息,不需要删除，直接修改
                string branksItem = "";
                for (int i = 0; i < cbRefBranks.Items.Count; i++)
                {
                    if (cbRefBranks.Items[i].Selected == true)
                    {
                        branksItem += "," + cbRefBranks.Items[i].Value;
                    }
                }
                if (cbRefBranks.SelectedValue != "")
                {
                   branksItem = branksItem.Substring(1, branksItem.Length - 1);
                }
                int rows_RefBranks = bll_refbranks.Update_CNVP_ProTypeRefBranks(
                new Model.CNVP_ProTypeRefBranks()
                {
                    ProductTypeID = id,
                    BranksIDS = branksItem
                });
                #endregion
                #region 扩展属性
                string nowid_ProTypeRefExtendProperty = "";//存储当前ID
                try
                {
                    string ExtendPropertyName_Str = "";
                    byte StageShowType_Byte = 0;
                    string SelectItemValue_Str = "";
                    byte IsShow_Byte = 0;
                    int OrderID_Int = 0;
                    string[] CKProperty = Request.Form["CKProperty"].Split(Convert.ToChar(","));
                    for (int i = 0; i < CKProperty.Length; i++)//注意从‘1’开始
                    {
                        string[] valueExtendPropertyName = Request.Form["ExtendPropertyName"].Split(Convert.ToChar(","));
                        ExtendPropertyName_Str = valueExtendPropertyName[i].ToString();
                        string[] valueStageShowType = Request.Form["StageShowType"].Split(Convert.ToChar(","));
                        StageShowType_Byte = byte.Parse(valueStageShowType[i].ToString());
                        string[] valueSelectItemValue = Request.Form["SelectItemValue"].Split(Convert.ToChar(","));
                        SelectItemValue_Str = valueSelectItemValue[i].ToString();
                        string[] valueIsShow = Request.Form["IsShow"].Split(Convert.ToChar(","));
                        IsShow_Byte = byte.Parse(valueIsShow[i].ToString());
                        string[] OrderID = Request.Form["OrderID"].Split(Convert.ToChar(","));
                        try
                        {
                            OrderID_Int = int.Parse(OrderID[i].ToString());
                        }
                        catch { OrderID_Int = 0; }//注意这句
                        int CKPropertyid = 0;
                        if (CKProperty[i].ToString() != "on")//注意不空
                        {
                            CKPropertyid = int.Parse(CKProperty[i].ToString());
                        }
                        if (CKPropertyid > 0)
                        {

                            int ProTypeRefExtendProperty_Int = new BLL.CNVP_ProTypeRefExtendProperty().Update_CNVP_ProTypeRefExtendProperty(
                            new Model.CNVP_ProTypeRefExtendProperty()
                            {
                                ID = CKPropertyid,
                                ProductTypeID = id,
                                ExtendPropertyName = ExtendPropertyName_Str,
                                StageShowType = StageShowType_Byte,
                                SelectItemValue = SelectItemValue_Str,
                                IsShow = IsShow_Byte,
                                IsOrder = OrderID_Int
                            });
                            nowid_ProTypeRefExtendProperty += CKPropertyid + ",";
                        }
                        else
                        {
                            int ProTypeRefExtendProperty_Int = new BLL.CNVP_ProTypeRefExtendProperty().Add_CNVP_ProTypeRefExtendProperty(
                            new Model.CNVP_ProTypeRefExtendProperty()
                            {
                                ProductTypeID = id,
                                ExtendPropertyName = ExtendPropertyName_Str,
                                StageShowType = StageShowType_Byte,
                                SelectItemValue = SelectItemValue_Str,
                                IsShow = IsShow_Byte,
                                IsOrder = OrderID_Int
                            });
                            nowid_ProTypeRefExtendProperty += ProTypeRefExtendProperty_Int + ",";
                        }
                    }
                }
                catch{  }
                //删除不在当前的ID
                if (nowid_ProTypeRefExtendProperty.Length > 0)
                {
                    nowid_ProTypeRefExtendProperty = nowid_ProTypeRefExtendProperty.Substring(0, nowid_ProTypeRefExtendProperty.Length - 1);
                }
                else
                {
                    nowid_ProTypeRefExtendProperty = "0";
                }
                new BLL.CNVP_ProTypeRefExtendProperty().DeleteNotIn(id, nowid_ProTypeRefExtendProperty);
                new BLL.CNVP_ProExtendeProperty().DeleteNotIn(id, nowid_ProTypeRefExtendProperty);
                #endregion
                #region 购物必填
                string MustInfoName_Str = "";
                byte ShowWay_Byte = 0;
                string MustInfoValue_Str = "";
                string nowid_ProTypeRefShopMustInfo = "";//存储当前ID
                try
                {
                    string[] CKTabs5MustInfo = Request.Form["CKTabs5MustInfo"].Split(Convert.ToChar(","));
                    for (int i = 1; i < CKTabs5MustInfo.Length; i++)//注意从‘1’开始
                    {
                        string[] valueMustInfoName = Request.Form["MustInfoName"].Split(Convert.ToChar(","));
                        MustInfoName_Str = valueMustInfoName[i].ToString();
                        string[] valueShowWay = Request.Form["ShowWay"].Split(Convert.ToChar(","));
                        ShowWay_Byte = byte.Parse(valueShowWay[i].ToString());
                        string[] valueMustInfoValue = Request.Form["MustInfoValue"].Split(Convert.ToChar(","));
                        MustInfoValue_Str = valueMustInfoValue[i].ToString();
                        int CKMustInfoid = 0;
                        string xx = CKTabs5MustInfo[i].ToString();
                        if (CKTabs5MustInfo[i].ToString() != "on")//注意不空
                        {
                            CKMustInfoid = int.Parse(CKTabs5MustInfo[i].ToString());
                        }
                        if (CKMustInfoid > 0)
                        {

                           int ProTypeRefShopMustInfo_Int = new BLL.CNVP_ProTypeRefShopMustInfo().Update_CNVP_ProTypeRefShopMustInfo(
                           new Model.CNVP_ProTypeRefShopMustInfo()
                           {
                               ID=CKMustInfoid,
                               ProductTypeID = id,
                               MustInfoName = MustInfoName_Str,
                               ShowWay = ShowWay_Byte,
                               MustInfoValue = MustInfoValue_Str
                           });
                           nowid_ProTypeRefShopMustInfo += CKMustInfoid + ",";
                        }
                        else
                        {
                            int ProTypeRefShopMustInfo_Int = new BLL.CNVP_ProTypeRefShopMustInfo().Add_CNVP_ProTypeRefShopMustInfo(
                            new Model.CNVP_ProTypeRefShopMustInfo()
                            {
                                ProductTypeID = id,
                                MustInfoName = MustInfoName_Str,
                                ShowWay = ShowWay_Byte,
                                MustInfoValue = MustInfoValue_Str
                            });
                            nowid_ProTypeRefShopMustInfo += ProTypeRefShopMustInfo_Int + ",";
                        }
                    }
                }
                catch { }
                //删除不在当前的ID
                if (nowid_ProTypeRefShopMustInfo.Length > 0)
                {
                    nowid_ProTypeRefShopMustInfo = nowid_ProTypeRefShopMustInfo.Substring(0, nowid_ProTypeRefShopMustInfo.Length - 1);
                }
                else
                {
                    nowid_ProTypeRefShopMustInfo = "0";
                }
                new BLL.CNVP_ProTypeRefShopMustInfo().DeleteNotIn(id, nowid_ProTypeRefShopMustInfo);
                #endregion
                #region 详细参数
                string DescripttionName_Str = "";
                string nowid_ProTypeRefDescripttion = "";//存储当前ID
                try
                {
                    string[] CKTabs4Descripttion = Request.Form["CKTabs4Descripttion"].Split(Convert.ToChar(","));
                    for (int i = 1; i < CKTabs4Descripttion.Length; i++)//注意从‘1’开始
                    {
                        string[] valueDescripttionName = Request.Form["DescripttionName"].Split(Convert.ToChar(","));
                        DescripttionName_Str = valueDescripttionName[i].ToString();
                        int CKDescripttionid = 0;
                        if (CKTabs4Descripttion[i].ToString() != "on")//注意不空
                        {
                            CKDescripttionid = int.Parse(CKTabs4Descripttion[i].ToString());
                        }
                        if (CKDescripttionid > 0)
                        {
                            int ProTypeRefDescripttion_Int = new BLL.CNVP_ProTypeRefDescripttion().Update_CNVP_ProTypeRefDescripttion(
                            new Model.CNVP_ProTypeRefDescripttion()
                            {
                                ID=CKDescripttionid,
                                ProductTypeID = id,
                                DescripttionName = DescripttionName_Str
                            });
                            nowid_ProTypeRefDescripttion += CKDescripttionid + ",";
                        }
                        else
                        {
                            int ProTypeRefDescripttion_Int = new BLL.CNVP_ProTypeRefDescripttion().Add_CNVP_ProTypeRefDescripttion(
                            new Model.CNVP_ProTypeRefDescripttion()
                            {
                                ProductTypeID = id,
                                DescripttionName = DescripttionName_Str
                            });
                            nowid_ProTypeRefDescripttion += ProTypeRefDescripttion_Int + ",";
                        }
                    }
                }
                catch {  }
                //删除不在当前的ID
                if (nowid_ProTypeRefDescripttion.Length > 0)
                {
                    nowid_ProTypeRefDescripttion = nowid_ProTypeRefDescripttion.Substring(0, nowid_ProTypeRefDescripttion.Length - 1);
                }
                else
                {
                    nowid_ProTypeRefDescripttion = "0";
                }
                new BLL.CNVP_ProTypeRefDescripttion().DeleteNotIn(id, nowid_ProTypeRefDescripttion);
                new BLL.CNVP_ProPropertyDescripttion().DeleteNotIn(id, nowid_ProTypeRefDescripttion);
                #endregion
                #region 规格
                int StandardID_Int = 0;
                byte ddlShowWay_Byte = 0;
                string nowid_ProTypeRefStandard = "";//存储当前ID
                try
                {
                    string[] CKTab2Standard = Request.Form["CKTab2Standard"].Split(Convert.ToChar(","));
                    for (int i = 1; i < CKTab2Standard.Length; i++)//注意从‘1’开始
                    {
                        string[] valueddlStandardID = Request.Form["ddlStandardID"].Split(Convert.ToChar(","));
                        StandardID_Int = int.Parse(valueddlStandardID[i].ToString());
                        string[] valueddlShowWay = Request.Form["ddlShowWay"].Split(Convert.ToChar(","));
                        ddlShowWay_Byte = byte.Parse(valueddlShowWay[i].ToString());
                        int CKStandardid = 0;
                        if (CKTab2Standard[i].ToString() != "on")//注意不空
                        {
                            CKStandardid = int.Parse(CKTab2Standard[i].ToString());
                        }
                        if (CKStandardid > 0)
                        {
                            int ProTypeRefStandard_Int = new BLL.CNVP_ProTypeRefStandard().Update_CNVP_ProTypeRefStandard(
                            new Model.CNVP_ProTypeRefStandard()
                            {
                                ID=CKStandardid,
                                ProductTypeID = id,
                                StandardID = StandardID_Int,
                                ShowWay = ddlShowWay_Byte
                            });
                            nowid_ProTypeRefStandard += CKStandardid + ",";
                        }
                        else
                        {
                            int ProTypeRefStandard_Int = new BLL.CNVP_ProTypeRefStandard().Add_CNVP_ProTypeRefStandard(
                            new Model.CNVP_ProTypeRefStandard()
                            {
                                ProductTypeID = id,
                                StandardID = StandardID_Int,
                                ShowWay = ddlShowWay_Byte
                            });
                            nowid_ProTypeRefStandard += ProTypeRefStandard_Int + ",";
                        }
                    }
                }
                catch { }
                //删除不在当前的ID
                if (nowid_ProTypeRefStandard.Length > 0)
                {
                    nowid_ProTypeRefStandard = nowid_ProTypeRefStandard.Substring(0, nowid_ProTypeRefStandard.Length - 1);
                }
                else
                {
                    nowid_ProTypeRefStandard = "0";
                }
                new BLL.CNVP_ProTypeRefStandard().DeleteNotIn(id, nowid_ProTypeRefStandard);
                #endregion

                BasePage.MessageBox("修改成功", "ProductTypeList.aspx");
            }
            else
            {
                #region 插入商品类型
                int rows = new BLL.CNVP_ProductType().Add_CNVP_ProductType(
                       new Model.CNVP_ProductType()
                       {
                           ProTypeName = txtProTypeName.Text.Trim(),
                           IsEntityType = IsEntityType,
                           IsRefBranks = IsRefBranks,
                           IsRefExtendProperty = IsRefExtendProperty,
                           IsRefDescripttion = IsRefDescripttion,
                           IsRefShopMustInfo = IsRefShopMustInfo
                       }

               );
                #endregion
                #region 插入品牌关联信息
                string branksItem = "";
                for (int i = 0; i < cbRefBranks.Items.Count; i++)
                {
                    if (cbRefBranks.Items[i].Selected == true)
                    {
                        branksItem += "," + cbRefBranks.Items[i].Value;
                    }
                }
                if (cbRefBranks.SelectedValue != "")
                {
                    branksItem = branksItem.Substring(1, branksItem.Length - 1);
                }
                int rows_RefBranks = bll_refbranks.Add_CNVP_ProTypeRefBranks(
                    new Model.CNVP_ProTypeRefBranks()
                    {
                        ProductTypeID = rows,
                        BranksIDS = branksItem
                    });
                #endregion
                #region 扩展属性
                string ExtendPropertyName_Str = "";
                byte StageShowType_Byte = 0;
                string SelectItemValue_Str = "";
                byte IsShow_Byte = 0;
                int OrderID_Int = 0;
                try
                {
                    string[] CKProperty = Request.Form["CKProperty"].Split(Convert.ToChar(","));
                    for (int i = 0; i < CKProperty.Length; i++)//注意从‘1’开始
                    {
                        string[] valueExtendPropertyName = Request.Form["ExtendPropertyName"].Split(Convert.ToChar(","));
                        ExtendPropertyName_Str = valueExtendPropertyName[i].ToString();
                        string[] valueStageShowType = Request.Form["StageShowType"].Split(Convert.ToChar(","));
                        StageShowType_Byte = byte.Parse(valueStageShowType[i].ToString());
                        string[] valueSelectItemValue = Request.Form["SelectItemValue"].Split(Convert.ToChar(","));
                        SelectItemValue_Str = valueSelectItemValue[i].ToString();
                        string[] valueIsShow = Request.Form["IsShow"].Split(Convert.ToChar(","));
                        IsShow_Byte = byte.Parse(valueIsShow[i].ToString());
                        string[] OrderID = Request.Form["OrderID"].Split(Convert.ToChar(","));
                        try
                        {
                            OrderID_Int = int.Parse(OrderID[i].ToString());
                        }
                        catch { OrderID_Int = 0; }//注意这句
                        int ProTypeRefExtendProperty_Int = new BLL.CNVP_ProTypeRefExtendProperty().Add_CNVP_ProTypeRefExtendProperty(
                            new Model.CNVP_ProTypeRefExtendProperty()
                            {
                                ProductTypeID = rows,
                                ExtendPropertyName = ExtendPropertyName_Str,
                                StageShowType = StageShowType_Byte,
                                SelectItemValue = SelectItemValue_Str,
                                IsShow = IsShow_Byte,
                                IsOrder = OrderID_Int
                            });
                    }
                }
                catch { }
                #endregion
                #region 购物必填
                string MustInfoName_Str = "";
                byte ShowWay_Byte = 0;
                string MustInfoValue_Str = "";
                try
                {
                    string[] CKTabs5MustInfo = Request.Form["CKTabs5MustInfo"].Split(Convert.ToChar(","));
                    for (int i = 1; i < CKTabs5MustInfo.Length; i++)//注意从‘1’开始
                    {
                        string[] valueMustInfoName = Request.Form["MustInfoName"].Split(Convert.ToChar(","));
                        MustInfoName_Str = valueMustInfoName[i].ToString();
                        string[] valueShowWay = Request.Form["ShowWay"].Split(Convert.ToChar(","));
                        ShowWay_Byte = byte.Parse(valueShowWay[i].ToString());
                        string[] valueMustInfoValue = Request.Form["MustInfoValue"].Split(Convert.ToChar(","));
                        MustInfoValue_Str = valueMustInfoValue[i].ToString();
                        int ProTypeRefShopMustInfo_Int = new BLL.CNVP_ProTypeRefShopMustInfo().Add_CNVP_ProTypeRefShopMustInfo(
                            new Model.CNVP_ProTypeRefShopMustInfo()
                            {
                                ProductTypeID = rows,
                                MustInfoName = MustInfoName_Str,
                                ShowWay = ShowWay_Byte,
                                MustInfoValue = MustInfoValue_Str
                            });
                    }
                }
                catch { }
                #endregion
                #region 详细参数
                string DescripttionName_Str = "";
                try
                {
                    string[] CKTabs4Descripttion = Request.Form["CKTabs4Descripttion"].Split(Convert.ToChar(","));
                    for (int i = 1; i < CKTabs4Descripttion.Length; i++)//注意从‘1’开始
                    {
                        string[] valueDescripttionName = Request.Form["DescripttionName"].Split(Convert.ToChar(","));
                        DescripttionName_Str = valueDescripttionName[i].ToString();
                        int ProTypeRefDescripttion_Int = new BLL.CNVP_ProTypeRefDescripttion().Add_CNVP_ProTypeRefDescripttion(
                        new Model.CNVP_ProTypeRefDescripttion()
                        {
                            ProductTypeID = rows,
                            DescripttionName = DescripttionName_Str
                        });
                    }
                }
                catch { }
                #endregion
                #region 规格
                int StandardID_Int = 0;
                byte ddlShowWay_Byte = 0;
                try
                {
                    string[] CKTab2Standard = Request.Form["CKTab2Standard"].Split(Convert.ToChar(","));
                    for (int i = 1; i < CKTab2Standard.Length; i++)//注意从‘1’开始
                    {
                        string[] valueddlStandardID = Request.Form["ddlStandardID"].Split(Convert.ToChar(","));
                        StandardID_Int = int.Parse(valueddlStandardID[i].ToString());
                        string[] valueddlShowWay = Request.Form["ddlShowWay"].Split(Convert.ToChar(","));
                        ddlShowWay_Byte = byte.Parse(valueddlShowWay[i].ToString());
                        int ProTypeRefStandard_Int = new BLL.CNVP_ProTypeRefStandard().Add_CNVP_ProTypeRefStandard(
                        new Model.CNVP_ProTypeRefStandard()
                        {
                            ProductTypeID = rows,
                            StandardID = StandardID_Int,
                            ShowWay = ddlShowWay_Byte
                        });
                    }
                }
                catch { }
                #endregion

                BasePage.MessageBox("添加成功", "ProductTypeList.aspx");
            }
        }

        protected void rptListTabs2_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            //方法一
            if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer)
            {
                Label lbStandard = (Label)e.Item.FindControl("lbStandard");
                Label lbStandardID = (Label)e.Item.FindControl("lbStandardID");

                CNVP.JShop.Model.CNVP_Standard model_Standard = new CNVP.JShop.Model.CNVP_Standard();
                CNVP.JShop.BLL.CNVP_Standard bll_Standard = new CNVP.JShop.BLL.CNVP_Standard();
                DataTable dt = bll_Standard.GetTableBySqlWhere("");
                optionEditNull = "<select id=\"ddlStandardID\" name=\"ddlStandardID\">";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    string relSelect = "";
                    if (dt.Rows[i]["ID"].ToString() == lbStandardID.Text)
                    {
                        relSelect = "selected='selected'";
                    }
                    optionEditNull += " <option title=\"" + dt.Rows[i]["StandardOtherName"].ToString() + "\" value=\"" + dt.Rows[i]["ID"].ToString() + "\" " + relSelect + ">" + dt.Rows[i]["StandardName"].ToString() + "</option>";
                }
                optionEditNull += "</select>";
                lbStandard.Text = optionEditNull;
            }
        }
    }
}
